import request from '@/utils/request'

//商店管理
const PRODUCT_URL = 'api/admin/product'

//添加商品
export const addProduct = (produt)=>{
    return request.post(PRODUCT_URL,produt)
}

//修改商品
export const updateProduct = (produt)=>{
    return request.put(PRODUCT_URL,produt)
}

//批量删除商品
export const deleteProducts = (ids)=>{
    return request.delete(PRODUCT_URL,ids)
}

//根据目录id查询菜品列表
export const productList = (categoryId)=>{
    return request.post(PRODUCT_URL+'/list',{
        params:{
            categoryId:categoryId
        }
    })
}

//商品的起售和停售
export const ProductStatus = (status,id)=>{
    // console.log('ProductStatus'+status+','+id)
    return request.post(PRODUCT_URL+'/status/'+status+'?id='+id)
}

//商品分页查询
export const productPage = (categoryId,name,page,pageSize,status)=>{
    return request.get(PRODUCT_URL+'/page',{
        params:{
            categoryId:categoryId,
            name:name,
            page:page,
            pageSize:pageSize,
            status:status
        }
    })
}

//根据id查询商品
export const queryProductById = (id)=>{
    // console.log(typeof id)
    return request.get(PRODUCT_URL+'/'+id)
}